import mysql.connector as mysql_conn


def get_conn():
    try:
        conn = mysql_conn.connect(host='localhost',
                                  database='cinema_system',
                                  user='root',
                                  password='18213859670Lsy',
                                  charset='utf8',
                                  autocommit=True
                                  )
        return conn
    except mysql_conn.Error:
        print("数据库连接异常")

def close_conn(conn,cursor):
    try:
        if cursor:
            cursor.close()
        if conn:
            conn.close()
    except mysql_conn.Error:
        print('ababa')
    finally:
        cursor.close()
        conn.close()

print(get_conn())